package com.ulife.permission.common;

import java.io.Serializable;

/**
 * 系统登录用户
 * 保存到cookie中
 */
public class SysUser implements Serializable {
	private static final long serialVersionUID = 619675878090089857L;

	private static final ThreadLocal<SysUser> userHolder       = new ThreadLocal<SysUser>();
	private long id;
    private String name;
    private String department;
    
    public static final SysUser getCurrentUser() {
        return (SysUser) userHolder.get();
    }
    
    public static final void setCurrentUser(SysUser user) {
        userHolder.set(user);
    }
    
	public SysUser(long id, String name, String department) {
		super();
		this.id = id;
		this.name = name;
		this.department = department;
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public boolean hasLoggedIn() {
        return id > 0;
    }
}
